<template>
	<view>
		<header class="header header_index clearfix" v-if="isIndex">
			<div class="header_left">
				<a href="/" class="">
					<img :src="config.staticImgUrl+'logo.png'" /> </a>
			</div>
			<h2>
				<input type="text" class="search" placeholder="">
				<i class="index_icon1"><img :src="config.staticImgUrl+'index_icon1.png'" alt="" /></i>
			</h2>
		</header>

		<header class="header header_index clearfix" v-else>
			<div class="header_left">
				<img :src="config.staticImgUrl +'/logo.png'" @tap="goPage('/')" />
			</div>
		</header>

		<div class="header_line clearfix"></div>

		<div class="content grey">


			<section class="index_st1 clearfix" v-show="config.banner.title!='test'">
				<figure id="responsiveness" class="swipslider">
					<ul class="sw-slides">
						<li class="sw-slide" v-for="(d,i) in config.banner" @tap="goDetail(d)">
							<img :src='config.staticUrl+d.pic'>
						</li>
					</ul>
				</figure>
			</section>

			<section class="index_st2 clearfix">
				<div class="index_st2_li" v-for="(data,i) in config.tabs" @tap="goPage(data.url)">
					<div class="index_st2_ct2">
						<a href="#" v-if="path==data.url">{{data.name}}</a>
						<block v-else>{{data.name}}</block>
					</div>
				</div>
			</section>
		</div>
		<df-form-phone :showIcon="false" :open="openFormStatusPhone"></df-form-phone>
		<df-form :showIcon="true" :open="openFormStatus"></df-form>
	</view>
</template>



<script type="text/javascript">
	$(window).load(function() {

	});
</script>
<script>
	import $ from "@/static/js/jquery-2.1.1.min.js";
	window.jQuery = $;
	require("@/static/js/swipeslider.min.js");
	export default {
		props: {
			isIndex: {
				default: false
			},
			// 控制菜单显示
			type: {
				default: 0
			}
		},
		data() {
			return {
				openFormStatus: false,
				openFormStatusPhone: false,
				config: this.$config,
				path: ''
			}
		},
		// 类似于onload
		mounted() {			
			// 延迟加载，保证元素已经渲染
			setTimeout(function() {
				// 避免重复加载
				if ($('.sw-bullet').length == 0) {
					$('#full_feature').swipeslider();
					$('#content_slider').swipeslider({
						transitionDuration: 600,
						autoPlayTimeout: 10000,
						sliderHeight: '300px'
					});
					$('#responsiveness').swipeslider();
					$('#customizability').swipeslider({
						transitionDuration: 1500,
						autoPlayTimeout: 4000,
						timingFunction: 'cubic-bezier(0.38, 0.96, 0.7, 0.07)',
						sliderHeight: '30%'
					});
				}
			}, 500)
		},
		// 重新渲染模板时调用
		created() {			
			this.init();
		},
		methods: {
			init: function() {
				// var path = window.location.hash;
				var path = this.$Router.$route.history.current.path;
				if (this.type != 0) {
					path = this.type;
				}

				// console.log(this.type);
				// console.log(this.config.tabs);
				// console.log(path);
				// console.log(this.config.banner);
				this.path = path;
			},
			goPage: function(e) {
				// console.log(e)
				if (e == '/') {
					this.$functions.goPage(e);
					return;
				}
				var _this = this;
				var phoneVerify = this.$functions.getCache('phoneVerify');
				phoneVerify.then(function(x) {
					// console.log("phoneVerify:" + x)
					// 调用弹窗
					if (!x && e == "/baoguang")
						_this.openFormPhone();
					//直接跳转 
					else
						_this.$functions.goPage(e);
				})
			},
			// 轮播图跳转
			goDetail: function(e) {
				var _this = this;
				e.video = "";
				e.Id = e.src.split('/').pop().replace('.html', '');
				console.log(e);
				// return;
				var phoneVerify = this.$functions.getCache('phoneVerify');
				phoneVerify.then(function(x) {
					console.log("phoneVerify:" + x)
					var type = e.typeId;
					if (!x && type == 'baoguang')
						_this.openFormPhone();
					else
						_this.$functions.goDetail(e, _this);
				})
			},
			openFormPhone() {
				// 轮流切换open值，触发模板里的watch函数
				this.openFormStatusPhone = this.openFormStatusPhone ? false : true;
				console.log('openFormPhone');
			},
			openForm() {
				// 轮流切换open值，触发模板里的watch函数
				this.openFormStatus = this.openFormStatus ? false : true;
				console.log('openForm');
			}
		}


	}
</script>

<style lang="scss">
	@import '@/static/css/online/index.scss';
</style>
